home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1988 / Oct⁄Nov 88 / Rr- Class Variables ⁄ 11.08.88 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.2 KB  |  34 lines  |  [TEXT/GEOL]

  1. Item    7232961                         8-Nov-88        07:08
  2.  
  3. From:   PASCOE1                         Pascoe, Geoff
  4.  
  5. To:     D1220                           VarLite, Dev, Andy Meldrum
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.  
  9. Sub:    Response to Class Variables...
  10.  
  11. Andy,
  12.  
  13. The thing about class variables (as they exist in Smalltalk) is that all
  14. subclasses should have access to the same variable also.  By simply declaring a
  15. variable in the implementation subclasses in different source files normally
  16. don't have that type of shared access.
  17.  
  18. One technique you can use to solve this- I've used variants of this frequently
  19. in Objective-C- is to create two methods in the class for querying and setting
  20. the variable.  Subclasses will inherit these methods and have similar access.
  21. Of course you pay a speed penalty.
  22.  
  23. A variant of this that is potentially more efficient is to have one method that
  24. returns a pointer to the class variable.  If subclasses store this locally they
  25. don't have subsequent method call overhead.
  26.  
  27. A side bonus is that unlike Smalltalk you can actually OVERRIDE the class
  28. variable in subclasses.  This really makes it more similar to Smalltalk's CLASS
  29. INSTANCE VARIABLE.
  30.  
  31. Geoff
  32.  
  33.  
  34.